Skip to content

[FEATURE] add response, maximum SPL, radiation impedance, closed box and horn profile to pytta.loudspeaker - #116

Open
aguirreSL wants to merge 3 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-loudspeaker_tools
Open

aguirreSL wants to merge 3 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-loudspeaker_tools

Conversation

@aguirreSL

@aguirreSL aguirreSL commented Nov 1, 2026 •

Copy link
Copy Markdown

Adds to pytta.loudspeaker the loudspeaker tools of the measurement application of the ITA-Toolbox that build on the Thiele-Small parameters (ita_thielesmall2velocity, ita_loudspeakertools_maxSPL, ita_radiation_impedance, ita_enclosure_fit for the closed box, ita_calculate_horn_geometry, ita_thiele_small_fit, ita_thiele_small_fit_weighted, ita_inductance_fit and ita_curvefit_inductance):

  1. response(params, freq, area, voltage=2.83, distance=1): the small signal response of the driver in an infinite baffle, with the diaphragm velocity and displacement, the current, the pressure on axis and its SPL, the radiated power and the efficiency.
  2. max_spl(params, freq, area, xmax, power_max): the largest SPL at each frequency limited by the peak excursion and by the power in Re, with the voltage and which limit applies.
  3. radiation_impedance(freq, radius): the impedance of a rigid piston in an infinite baffle, with the Bessel and Struve functions (Beranek and Mellow, Acoustics: Sound Fields and Transducers, 2012, eqs. 13.117 and 13.118).
  4. closed_box(params, Vb): fc = fs √(1 + Vas / Vb) and Qtc = Qts √(1 + Vas / Vb) without box losses (Small 1972; Beranek and Mellow, eq. 7.28).
  5. horn_profile(throat_area, cutoff, length, a=1): the area along a hyperbolic-exponential horn, from hyperbolic (a = 0) to exponential (a = 1), with xT = c / (2π fc) (Beranek and Mellow, eqs. 9.39, 9.51 and 9.58).
  6. fit_with_velocity(freq, impedance, velocity, weights=None): Re, Le, Bl, Rms, Mms and Cms from the impedance and the diaphragm velocity per volt measured together, by two linear least squares problems, Z = Re + jωLe + Bl G and Bl / G = Rms + jωMms + 1 / (jωCms) with G = v / i, optionally weighted per frequency.
  7. voice_coil_model(params, freq) and fit_voice_coil(freq, blocked, model='L2R2', Re=None): the blocked impedance of the voice coil, Re + jωLe, the L2R2 model with an eddy current branch, or Re + K (jω)^n (Leach, "Loudspeaker voice-coil inductance losses", J. Audio Eng. Soc. 50(6), 2002), and its least squares fit.

This pull request builds on #82 and shows its commits until #82 is merged. The ITA functions belong to an application of the ITA-Toolbox whose license is "all rights reserved", so only their help text was read and the functions are written from the references. The equalization, IIR model and impulse response shortening of that application are covered by invert_spectrum (#113), invfreqz (#110) and time_window (#49).

The tests, added to tests/test_loudspeaker.py, print the measured values:

  1. In the mid band (mass controlled, ka = 0.15) the efficiency is 5.310e-7 for ρ Bl² Sd² / (2π c Re Mms²) = 5.290e-7 (Beranek and Mellow, eq. 6.47), within 0.4 %.
  2. The radiation impedance follows (ka)²/2 and 8ka / (3π) at ka = 0.01 within 1e-4 and tends to ρcS at high frequencies.
  3. max_spl gives the voltage at which the peak excursion is exactly xmax at 20 and 40 Hz and the power in Re exactly power_max at 1 kHz.
  4. A driver with fs = 30 Hz, Qts = 0.35 and Vas = 3 Vb gives fc = 60 Hz and Qtc = 0.7, and the horn with a = 1 is the exponential St e^(mx) with m = 4π fc / c.
  5. The impedance and velocity of the lumped model with Le give back all its parameters (1.2e-12), and the L2R2 and Leach models are fitted back from their own curves.

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of development (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

aguirreSL and others added 2 commits October 31, 2026 21:56
New module pytta.loudspeaker estimates the small signal parameters of an
electrodynamic loudspeaker from its electrical impedance, given as a
SignalObj or as (freq, Z) arrays.

thiele_small reads fs, Re, Qms, Qes and Qts from the impedance peak and
the two frequencies where |Z| = sqrt(Rmax Re) (Small 1972; Beranek and
Mellow 2012, section 6.10). A second curve with an added mass or in a
closed box of known volume gives Mms, Cms, Rms, Bl and Vas. With
fit=True every curve is refined by a least squares fit of the lumped
model, which also returns Le and removes the bias that Le causes in the
closed form.

impedance_model returns Z = Re + j w Le + Zmot of the same model.

Six tests: recovery of the parameters from synthetic curves for the
impedance, added mass, added volume and fit methods, parity with
ita_linear_loudspeaker and ita_thiele_small of the ITA-Toolbox (golden
data and generator script in tests/golden), and rejection of invalid
input.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…horn profile to pytta.loudspeaker

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…eaker

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant